*** This do file creates figure B3 for the minimum wage precomittment paper
*** using the year of first statutory increase as the first treatment year
*** and separating large and small statutory increaser states


set more off
capture log close
clear all
* If needed change global path to point to directory where files are stored on your computer
*global path "I:/DataSets5/Duncan/Dropbox/Recent Minimum Wage Changes/2020.12 NBER Update/JOLE Precommittment Replication"
global dtadir "$path/Data"
global tabdir "$path/Tables"
global figdir "$path/Figures"
global estdir "$path/Estimates"
global logdir "$path/Logfiles"

log using "$logdir/event-time-event-study-graphs-policy-categories-drop-indexers.log", replace


**** LOW-SKILLED INDIVIDUALS AGES 16-25 WITH LESS THAN A COMPLETED HIGH-SCHOOL EDUCATION

*** Least-skilled baseline controls
use "$estdir/EventTimePolicyCategories/EventTimeRegressionEmploymentLeastNoControls.dta", clear

* Add observation
insobs 1

* Manually add 0 for year prior to first increase, which is the baseline period for the event study 
replace parm = "largeinctimeNOIzero" if parm == "_cons"
replace parm = "smallinctimeNOIzero" if _n == 16

replace estimate = 0 if parm == "largeinctimeNOIzero"
replace stderr = 0 if parm == "largeinctimeNOIzero"
replace min95 = 0 if parm  == "largeinctimeNOIzero"
replace max95 = 0 if parm  == "largeinctimeNOIzero"

replace estimate = 0 if parm == "smallinctimeNOIzero"
replace stderr = 0 if parm == "smallinctimeNOIzero"
replace min95 = 0 if parm  == "smallinctimeNOIzero"
replace max95 = 0 if parm  == "smallinctimeNOIzero"

** Generate year variable
gen year =.
replace year = -3 if strpos(parm, "neg3plus")
replace year = -2 if strpos(parm, "neg2")
replace year = -1 if strpos(parm, "neg1")
replace year = 0 if strpos(parm, "zero")
replace year = 1 if strpos(parm, "pos1")
replace year = 2 if strpos(parm, "pos2")
replace year = 3 if strpos(parm, "pos3")
replace year = 4 if strpos(parm, "pos4plus")

* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "largeinctimeNOI"), year - 0.1, cond(strpos(parm, "smallinctimeNOI"), year + 0.1, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "smallinctimeNOI")
replace policygroup = 2 if strpos(parm, "largeinctimeNOI")


label define grouplbl 1 "Small" 2 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 2, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel A: Low-Skilled with No Controls", size(medsmall) color(black)) ///
	legend(order(1 3) label(1 "Large Increasers") label(3 "Small Increasers") rows(1) region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeLeastNoControls, replace)

*** Least-skilled baseline controls
use "$estdir/EventTimePolicyCategories/EventTimeRegressionEmploymentLeastBaseControls.dta", clear

* Manually add 0 for year prior to first increase, which is the baseline period for the event study
replace parm = "largeinctimeNOIzero" if parm == "HPI" 
replace parm = "smallinctimeNOIzero" if parm == "lnPersonalIncome" 
drop if parm == "_cons" 

replace estimate = 0 if parm == "largeinctimeNOIzero"
replace stderr = 0 if parm == "largeinctimeNOIzero"
replace min95 = 0 if parm  == "largeinctimeNOIzero"
replace max95 = 0 if parm  == "largeinctimeNOIzero"

replace estimate = 0 if parm == "smallinctimeNOIzero"
replace stderr = 0 if parm == "smallinctimeNOIzero"
replace min95 = 0 if parm  == "smallinctimeNOIzero"
replace max95 = 0 if parm  == "smallinctimeNOIzero"

** Generate year variable
gen year =.
replace year = -3 if strpos(parm, "neg3plus")
replace year = -2 if strpos(parm, "neg2")
replace year = -1 if strpos(parm, "neg1")
replace year = 0 if strpos(parm, "zero")
replace year = 1 if strpos(parm, "pos1")
replace year = 2 if strpos(parm, "pos2")
replace year = 3 if strpos(parm, "pos3")
replace year = 4 if strpos(parm, "pos4plus")

* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "largeinctimeNOI"), year - 0.1, cond(strpos(parm, "smallinctimeNOI"), year + 0.1, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "smallinctimeNOI")
replace policygroup = 2 if strpos(parm, "largeinctimeNOI")


label define grouplbl 1 "Small" 2 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 2, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel B: Low-Skilled with Sparse Controls", size(medsmall) color(black)) ///
	legend(order(1 3) label(1 "Large Increasers") label(3 "Small Increasers") rows(1) region(lstyle(none)) size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeLeastBaseControls, replace)

*** Least-skilled rich controls
use "$estdir/EventTimePolicyCategories/EventTimeRegressionEmploymentLeastRichControls.dta", clear

* Drop unneded variables
drop if substr(parm,1,1) == "D"

* Manually add 0 for year prior to first increase, which is the baseline period for the event study
replace parm = "largeinctimeNOIzero" if parm == "HPI" 
replace parm = "smallinctimeNOIzero" if parm == "lnPersonalIncome" 
drop if parm == "_cons" 

replace estimate = 0 if parm == "largeinctimeNOIzero"
replace stderr = 0 if parm == "largeinctimeNOIzero"
replace min95 = 0 if parm  == "largeinctimeNOIzero"
replace max95 = 0 if parm  == "largeinctimeNOIzero"

replace estimate = 0 if parm == "smallinctimeNOIzero"
replace stderr = 0 if parm == "smallinctimeNOIzero"
replace min95 = 0 if parm  == "smallinctimeNOIzero"
replace max95 = 0 if parm  == "smallinctimeNOIzero"


* Generate year variable
gen year =.
replace year = -3 if strpos(parm, "neg3plus")
replace year = -2 if strpos(parm, "neg2")
replace year = -1 if strpos(parm, "neg1")
replace year = 0 if strpos(parm, "zero")
replace year = 1 if strpos(parm, "pos1")
replace year = 2 if strpos(parm, "pos2")
replace year = 3 if strpos(parm, "pos3")
replace year = 4 if strpos(parm, "pos4plus")

* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "largeinctimeNOI"), year - 0.1, cond(strpos(parm, "smallinctimeNOI"), year + 0.1, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "smallinctimeNOI")
replace policygroup = 2 if strpos(parm, "largeinctimeNOI")


label define grouplbl 1 "Small" 2 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 2, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel C: Low-Skilled with Rich Controls", size(medsmall) color(black)) ///
	legend(order(1 3) label(1 "Large Increasers") label(3 "Small Increasers") rows(1) nobox size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeLeastRichControls, replace)



*** Young No Controls
use "$estdir/EventTimePolicyCategories/EventTimeRegressionEmploymentYoungNoControls.dta", clear

* Add observation
insobs 1

* Manually add 0 for year prior to first increase, which is the baseline period for the event study 
replace parm = "largeinctimeNOIzero" if parm == "_cons"
replace parm = "smallinctimeNOIzero" if _n == 16


replace estimate = 0 if parm == "largeinctimeNOIzero"
replace stderr = 0 if parm == "largeinctimeNOIzero"
replace min95 = 0 if parm  == "largeinctimeNOIzero"
replace max95 = 0 if parm  == "largeinctimeNOIzero"

replace estimate = 0 if parm == "smallinctimeNOIzero"
replace stderr = 0 if parm == "smallinctimeNOIzero"
replace min95 = 0 if parm  == "smallinctimeNOIzero"
replace max95 = 0 if parm  == "smallinctimeNOIzero"


* Generate year variable
gen year =.
replace year = -3 if strpos(parm, "neg3plus")
replace year = -2 if strpos(parm, "neg2")
replace year = -1 if strpos(parm, "neg1")
replace year = 0 if strpos(parm, "zero")
replace year = 1 if strpos(parm, "pos1")
replace year = 2 if strpos(parm, "pos2")
replace year = 3 if strpos(parm, "pos3")
replace year = 4 if strpos(parm, "pos4plus")


* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "largeinctimeNOI"), year - 0.1, cond(strpos(parm, "smallinctimeNOI"), year + 0.1, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "smallinctimeNOI")
replace policygroup = 2 if strpos(parm, "largeinctimeNOI")


label define grouplbl 1 "Small" 2 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 2, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel D: Young with No Controls", size(medsmall) color(black)) ///
	legend(order(1 3) label(1 "Large Increasers") label(3 "Small Increasers") rows(1) nobox size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeYoungNoControls, replace)

*** Young Baseline Controls
use "$estdir/EventTimePolicyCategories/EventTimeRegressionEmploymentYoungBaseControls.dta", clear

* Manually add 0 for year prior to first increase, which is the baseline period for the event study
replace parm = "largeinctimeNOIzero" if parm == "HPI" 
replace parm = "smallinctimeNOIzero" if parm == "lnPersonalIncome" 
drop if parm == "_cons"

replace estimate = 0 if parm == "largeinctimeNOIzero"
replace stderr = 0 if parm == "largeinctimeNOIzero"
replace min95 = 0 if parm  == "largeinctimeNOIzero"
replace max95 = 0 if parm  == "largeinctimeNOIzero"

replace estimate = 0 if parm == "smallinctimeNOIzero"
replace stderr = 0 if parm == "smallinctimeNOIzero"
replace min95 = 0 if parm  == "smallinctimeNOIzero"
replace max95 = 0 if parm  == "smallinctimeNOIzero"


* Generate year variable
gen year =.
replace year = -3 if strpos(parm, "neg3plus")
replace year = -2 if strpos(parm, "neg2")
replace year = -1 if strpos(parm, "neg1")
replace year = 0 if strpos(parm, "zero")
replace year = 1 if strpos(parm, "pos1")
replace year = 2 if strpos(parm, "pos2")
replace year = 3 if strpos(parm, "pos3")
replace year = 4 if strpos(parm, "pos4plus")


* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "largeinctimeNOI"), year - 0.1, cond(strpos(parm, "smallinctimeNOI"), year + 0.1, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "smallinctimeNOI")
replace policygroup = 2 if strpos(parm, "largeinctimeNOI")


label define grouplbl 1 "Small" 2 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 2, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel E: Young with Sparse Controls", size(medsmall) color(black)) ///
	legend(order(1 3) label(1 "Large Increasers") label(3 "Small Increasers") rows(1) nobox size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeYoungBaseControls, replace)



*** Young Rich Controls
use "$estdir/EventTimePolicyCategories/EventTimeRegressionEmploymentYoungRichControls.dta", clear

* Drop unneded variables
drop if substr(parm,1,1) == "D"

* Manually add 0 for year prior to first increase, which is the baseline period for the event study
replace parm = "largeinctimeNOIzero" if parm == "HPI" 
replace parm = "smallinctimeNOIzero" if parm == "lnPersonalIncome" 
drop if parm == "_cons"


replace estimate = 0 if parm == "largeinctimeNOIzero"
replace stderr = 0 if parm == "largeinctimeNOIzero"
replace min95 = 0 if parm  == "largeinctimeNOIzero"
replace max95 = 0 if parm  == "largeinctimeNOIzero"

replace estimate = 0 if parm == "smallinctimeNOIzero"
replace stderr = 0 if parm == "smallinctimeNOIzero"
replace min95 = 0 if parm  == "smallinctimeNOIzero"
replace max95 = 0 if parm  == "smallinctimeNOIzero"

* Generate year variable
gen year =.
replace year = -3 if strpos(parm, "neg3plus")
replace year = -2 if strpos(parm, "neg2")
replace year = -1 if strpos(parm, "neg1")
replace year = 0 if strpos(parm, "zero")
replace year = 1 if strpos(parm, "pos1")
replace year = 2 if strpos(parm, "pos2")
replace year = 3 if strpos(parm, "pos3")
replace year = 4 if strpos(parm, "pos4plus")


* Make graph with point estimates and standard errors
clonevar _mx = year

replace _mx = cond(strpos(parm, "largeinctimeNOI"), year - 0.1, cond(strpos(parm, "smallinctimeNOI"), year + 0.1, year))

gen policygroup = 0
replace policygroup = 1 if strpos(parm, "smallinctimeNOI")
replace policygroup = 2 if strpos(parm, "largeinctimeNOI")


label define grouplbl 1 "Small" 2 "Large"
label values policygroup grouplbl

sort policygroup year

graph twoway (scatter estimate _mx if policygroup == 2, msymbol(circle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 2, lcolor(black)) ///
	(scatter estimate _mx if policygroup == 1, msymbol(triangle) mcolor(black) msize(medium) lcolor(black)) || (rspike min95 max95 _mx if policygroup == 1, lcolor(black)), ///
	yline(0, lcolor(black)) ///
	title("Panel F: Young with Rich Controls", size(medsmall) color(black)) ///
	legend(order(1 3) label(1 "Large Increasers") label(3 "Small Increasers") rows(1) nobox size(small) symxsize(small)) ///
	ylabel(-.075 "-.075" -0.05 "-.050" -0.025 "-.025" 0 "0" .025 ".025", labsize(small) gmin gmax) ///
	xtitle("") ytitle("") bgcolor(white) graphregion(color(white)) bgcolor(white) /// 
	xlabel(-3 "-3+" -2 "-2" -1 "-1" 0 "0" 1 "1" 2 "2" 3 "3" 4 "4+", labsize(small)) xscale(range(-3 4)) ///
	name(EventTimeYoungRichControls, replace)


* Combine graphs to make a 6-panel figure
set graph on
graph dir // These named graphs are now in memory

*
grstyle init
grstyle color background white
grstyle graphsize x 20
grstyle graphsize y 11
grstyle set legend, nobox
*/

* Combined employment graph
grc1leg2  EventTimeLeastNoControls  EventTimeLeastBaseControls EventTimeLeastRichControls EventTimeYoungNoControls EventTimeYoungBaseControls EventTimeYoungRichControls, ///
	l1("Change", size(medsmall)) b1("Event Time", size(medsmall)) ring(2) xsize(20) ysize(11) margins(tiny) ///
	legendfrom(EventTimeLeastBaseControls) lsize(medmall) graphregion(color(white))
graph save "$figdir/event-time-figure-policy-categories-drop-all-indexers.gph", replace
graph export "$figdir/event-time-figure-policy-categories-drop-all-indexers.pdf", as(pdf) replace
